<template>
  <div class="orderconfirm-page">
    <div class="orderconfirm-contain">
      <div class="orderconfirm-top">
        <van-nav-bar title="商品列表" right-text="" left-arrow @click-left="onClickLeft" />
      </div>
      <div class="orderconfirm-content" ref="orderconfirm_page">
        <div class="orderconfirm">
          <div class="orderdetail-check">
            <ul class="order-list-wrap">
              <li v-for="item in orderDetailInfo.list" @click="goProductDetail(item.id)" class="">
                <div class="order-list-l">
                  <img :src="item.thumb">
                  <div class="order-list-name">
                    {{item.title}}
                  </div>
                </div>
                <div class="order-list-r">
                  <div class="order-list-price">
                    <span ng-bind="item.better_balance_price / 100 | price: '¥'" style="color: rgb(255, 72, 145);">¥{{item.price}}</span>
                  </div>
                  <div class="order-list-count">x{{item.quantity}}</div>
                </div>
              </li>
            </ul>
          </div>
          <div class="transparent-bg"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BScroll from 'better-scroll'
import Vue from 'vue'
import { NavBar, Icon } from 'vant'
import {CODE, APIURI} from '#/common/js/apiConst'
Vue.use(NavBar).use(Icon)
export default {
  data() {
    return {
      orderDetailInfo: {}
    }
  },
  created() {
    this.$nextTick(() => {
      this.getorderGoods()
      this._initScroll()
    })
  },
  methods: {
    _initScroll() {
      if (!this.ordersScroll) {
        this.ordersScroll = new BScroll(this.$refs.orderconfirm_page, {
          probeType: 3,
          scrollY: true,
          click: true
        })
      } else {
        this.ordersScroll.refresh()
      }
    },
    onClickLeft() {
      this.$router.push({
        path: '/orderconfirm'
      })
    },
    goProductDetail(id) {
      this.$router.push({
        path: '/detail?id=' + id
      })
    },
    getorderGoods() {
      this.$axios
        .get(APIURI + '/cart')
        .then(res => {
          res = res.data
          if (res.code === CODE) {
            this.orderDetailInfo = res.data
            this.orderDetailInfo.list = res.data.list.filter(el => {
              return el.choose
            })
          }
        })
        .catch(function(err) {
          console.log(err)
        })
    }
  }
}
</script>

<style lang="scss" scoped>
@import './../common/scss/common.scss';
.orderconfirm-page {
  width: 100%;
  .orderconfirm-top {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }
  .orderconfirm-content {
    width: 100%;
    height: 100vh;
    box-sizing: border-box;
    padding-top: 46px;
    overflow: hidden;
    .orderdetail-check {
      margin: 10px 0;
      padding: 0 15px;
      background-color: #fff;
      width: 100%;
      box-sizing: border-box;
      background-color: $white;
      .order-check-wrap {
        display: -webkit-box;
        display: -webkit-flex;
        display: -moz-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-direction: normal;
        -webkit-box-orient: horizontal;
        -webkit-flex-direction: row;
        -moz-flex-direction: row;
        -ms-flex-direction: row;
        flex-direction: row;
        -webkit-box-pack: justify;
        -ms-flex-pack: justify;
        -webkit-justify-content: space-between;
        -moz-justify-content: space-between;
        justify-content: space-between;
        line-height: 42px;
        font-size: 14px;
        .order-check-l {
          color: #4b4b4b;
        }
        .order-check-r {
          color: #ff4891;
        }
        .mf-chevron-down {
          display: inline-block;
          width: 10px;
          height: 6px;
          vertical-align: middle;
          background: url(https://static-as.missfresh.cn/frontend/img/mf-chevron-down.png)
            no-repeat;
          background-size: 100% 100%;
          margin-left: 5px;
          transform: rotate(180deg);
          -ms-transform: rotate(180deg);
          -webkit-transform: rotate(180deg);
          -o-transform: rotate(180deg);
          -moz-transform: rotate(180deg);
        }
        .mf-chevron-up {
          display: inline-block;
          width: 10px;
          height: 6px;
          vertical-align: middle;
          background: url(https://static-as.missfresh.cn/frontend/img/mf-chevron-down.png)
            no-repeat;
          background-size: 100% 100%;
          margin-left: 5px;
          transform: rotate(0deg);
          -ms-transform: rotate(0deg);
          -webkit-transform: rotate(0deg);
          -o-transform: rotate(0deg);
          -moz-transform: rotate(0deg);
        }
      }
      .order-list-wrap {
        li {
          position: relative;
          display: -webkit-box;
          display: -webkit-flex;
          display: -moz-flex;
          display: -ms-flexbox;
          display: flex;
          -webkit-box-direction: normal;
          -webkit-box-orient: horizontal;
          -webkit-flex-direction: row;
          -moz-flex-direction: row;
          -ms-flex-direction: row;
          flex-direction: row;
          -webkit-box-pack: row;
          -ms-flex-pack: row;
          -webkit-justify-content: row;
          -moz-justify-content: row;
          justify-content: row;
          border-bottom: 1px solid #e4e4e4;
          padding: 12px 0;
          .order-list-l {
            display: -webkit-box;
            display: -webkit-flex;
            display: -moz-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-direction: normal;
            -webkit-box-orient: horizontal;
            -webkit-flex-direction: row;
            -moz-flex-direction: row;
            -ms-flex-direction: row;
            flex-direction: row;
            -webkit-box-pack: row;
            -ms-flex-pack: row;
            -webkit-justify-content: row;
            -moz-justify-content: row;
            justify-content: row;
            -webkit-box-flex: 1;
            -webkit-flex: 1 1 auto;
            -moz-box-flex: 1;
            -moz-flex: 1 1 auto;
            -ms-flex: 1 1 auto;
            flex: 1 1 auto;
            img {
              border-radius: 4px;
              border: 1px solid #eceef0;
              margin-right: 10px;
              width: 50px;
              height: 50px;
            }
            .order-list-name {
              font-size: 14px;
              color: #4b4b4b;
              line-height: 25px;
            }
          }
          .order-list-r {
            width: 120px;
            -webkit-box-flex: 0;
            -webkit-flex: 0 0 120px;
            -moz-box-flex: 0;
            -moz-flex: 0 0 120px;
            -ms-flex: 0 0 120px;
            flex: 0 0 120px;
            text-align: right;
            line-height: 25px;
            .order-list-price {
              color: #ff4891;
              font-size: 14px;
            }
            .order-list-count {
              font-size: 12px;
            }
          }
          &:last-child {
            border-bottom: none;
          }
        }
      }
    }
    .transparent-bg {
      width: 100%;
      height: 56px;
      background-color: transparent;
    }
  }
}
</style>
